package com.lgx.mall.basic.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import net.sf.json.JSONObject;

import com.lgx.common.entity.IdGenerator;
import com.lgx.common.web.util.DateUtils;

/**
 * New entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "TM_NEWS")
public class News implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.TM_NEWS_ID)
	@TableGenerator(
			name = IdGenerator.TM_NEWS_ID,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.TM_NEWS_ID,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;
	
	private int type;        // 1新闻2公告3新手上路
	
	private String title;    //标题
	
	private String content;  //内容
	
	private String author;   //作者
	
	private Date time;       //发布时间
	
	private String layerOrder;     //排序方式，即我想要哪条信息显示在主界面上
	
	

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getLayerOrder() {
		return layerOrder;
	}

	public void setLayerOrder(String layerOrder) {
		this.layerOrder = layerOrder;
	}
	
	
	
	/**
	 * 新闻管理加载页面
	 * 公告管理加载页面
	 * 新手上路加载页面
	 */
	@Override
	public String toString() {
		JSONObject obj = new JSONObject();
		
		obj.put("id", this.getId());
		obj.put("title", this.getTitle());   		//标题  
		obj.put("content", this.getContent());      //正文  
		obj.put("author", this.getAuthor());        //作者
		obj.put("time", DateUtils.dateToChar(this.getTime(), DateUtils.DATE_FORMAT_D));   //发布时间  
		obj.put("layerOrder", this.getLayerOrder()); //排序方式
		return obj.toString();
	}

}
